{% set pypi_name = 'python-manilaclient' %}
{% set upstream_version = upstream_version('2.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Client Library for OpenStack Share API
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('python-openstackclient') }}
BuildRequires:  {{ py3('oslo.config') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.serialization') }}
BuildRequires:  {{ py3('oslo.utils') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testrepository') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Client library and command line utility for interacting with Openstack
Share API.

%package -n python3-manilaclient
Summary:        Client Library for OpenStack Share API
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('PrettyTable') }}
Requires:       {{ py3('debtcollector') }}
Requires:       {{ py3('python-keystoneclient') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('simplejson') }}
Requires:       {{ py3('six') }}
%if 0%{?suse_version}
Obsoletes:      {{ py2name(py_versions='py2') }} < 2.0.0
%endif

%description -n python3-manilaclient
Client library and command line utility for interacting with Openstack
Share API.

%package -n python-manilaclient-doc
Summary:        Documentation for OpenStack Share API Client
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('sphinxcontrib-programoutput') }}

%description -n python-manilaclient-doc
Client library and command line utility for interacting with Openstack
Share API.
This package contains auto-generated documentation.

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

PBR_VERSION={{ upstream_version }} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}


%install
%{py3_install}
# bash completion
install -p -D -m 644 tools/manila.bash_completion %{buildroot}%{_sysconfdir}/bash_completion.d/manila.bash_completion

%check
# we don't want to depend on Tempest so remove the relevant tests
rm -f manilaclient/tests/unit/test_shell.py
rm -f manilaclient/tests/unit/test_functional_utils.py
rm -rf manilaclient/tests/functional
python3 -m stestr.cli run

%files -n python3-manilaclient
%doc README.rst
%license LICENSE
%{python3_sitelib}/manilaclient
%{python3_sitelib}/*.egg-info
%{_bindir}/manila
%{_sysconfdir}/bash_completion.d/manila.bash_completion

%files -n python-manilaclient-doc
%license LICENSE
%doc doc/build/html

%changelog
